/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.istia.gesstages.actions;

import com.opensymphony.xwork2.ActionSupport;
import fr.istia.gesstages.metier.Metier;
import fr.istia.gesstages.metier.MetierService;
import fr.istia.gesstages.metier.User;
import java.util.Map;
import org.apache.struts2.interceptor.SessionAware;

public abstract class ParentAction extends ActionSupport implements SessionAware {

    // la session
    protected Map<String, Object> session;
    protected Metier metier = new MetierService().getMetierPort();
    
    public void setSession(Map<String, Object> map) {
        this.session = map;
    }
    
    public Boolean getIsAdmin(){
        Boolean isAnAdmin;
        try{
            isAnAdmin = ((User) session.get("user")).getType().getLibelle().equals("Administrateur");
        }
        catch(Exception e){
            isAnAdmin = false;
        }
        return isAnAdmin;
    }

    public Map<String, Object> getSession() {
        return session;
    }

    public Metier getMetier() {
        return metier;
    }

    public void setMetier(Metier metier) {
        this.metier = metier;
    }
}
